$(function() {
	var opts = {lang:'<?php echo $_GET['l'] ?>',styleWithCSS:true,cssfiles:['includes/wysiwyg/css/textarea.css'],height:250,toolbar:'maxi',fmOpen:function(callback){$('<div id="myelfinder" />').elfinder({url:'includes/wysiwyg/connector.php',lang : '<?php echo $_GET['l'] ?>',dialog:{width:700,modal:true,title:'Dateimanager'},closeOnEditorCallback:true,editorCallback:callback});}
	}
	$('#config').tabs({
		fx:{opacity:'toggle'},
		select: function(event, ui){
			var tabName = ui.panel.id;
			$('input#hidden_tab').val(tabName);
			window.location.hash = tabName;
			if (tabName == 'desc') {
				$('#tabs').tabs({fx:{opacity:'toggle'},
					show: function(event, ui){
						var lId = ui.panel.id.substring(9);
		        		setTimeout(function(){$('#categories_description_'+lId).elrte(opts);},500);
						setTimeout(function(){$('#categories_description_2_'+lId).elrte(opts);},800);
					},
					select: function(event, ui){
						var lId = ui.panel.id.substring(9);
						setTimeout(function(){$('#categories_description_'+lId).elrte(opts);},500);
						setTimeout(function(){$('#categories_description_2_'+lId).elrte(opts);},800);
					}
				});
    		}
    	},
    	show: function(event, ui){
			var tabName = ui.panel.id;
			$('input#hidden_tab').val(tabName);
			window.location.hash = tabName;
			if (tabName == 'desc') {
				$('#tabs').tabs({fx:{opacity:'toggle'},
					show: function(event, ui){
						var lId = ui.panel.id.substring(9);
						setTimeout(function(){$('#categories_description_'+lId).elrte(opts);},500);
						setTimeout(function(){$('#categories_description_2_'+lId).elrte(opts);},800);
					},
					select: function(event, ui){
						var lId = ui.panel.id.substring(9);
						setTimeout(function(){$('#categories_description_'+lId).elrte(opts);},500);
						setTimeout(function(){$('#categories_description_2_'+lId).elrte(opts);},800);
					}
				});
    		}
    	}
	});
	$('.category_data').fadeIn();
});